From 15c05dca326fb9e1862c166480032b84c88041e4 Mon Sep 17 00:00:00 2001 From: Steven Smith Date: Thu, 21 Sep 2006 17:56:14 +0100 Subject: [PATCH] [HVM] Reduce VNC overhead, by (a) only scanning framebuffer when a client is connected, and (b) fixing an overflow bug in the scanning code which prevented the dirty bit from ever getting cleared. Signed-off-by: Steven Smith --- tools/ioemu/hw/vga.c | 13 +++++++------ tools/ioemu/vnc.c | 13 ++++++------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tools/ioemu/hw/vga.c b/tools/ioemu/hw/vga.c index bbe3e582a5..6b9317f048 100644 --- a/tools/ioemu/hw/vga.c +++ b/tools/ioemu/hw/vga.c @@ -1463,14 +1463,15 @@ void check_sse2(void) */ static void vga_draw_graphic(VGAState *s, int full_update) { - int y1, y, update, page_min, page_max, linesize, y_start, double_scan, mask; + int y1, y, update, linesize, y_start, double_scan, mask; int width, height, shift_control, line_offset, bwidth; ram_addr_t page0, page1; int disp_width, multi_scan, multi_run; uint8_t *d; uint32_t v, addr1, addr; vga_draw_line_func *vga_draw_line; - + ram_addr_t page_min, page_max; + full_update |= update_basic_params(s); s->get_resolution(s, &width, &height); @@ -1561,8 +1562,8 @@ static void vga_draw_graphic(VGAState *s, int full_update) addr1 = (s->start_addr * 4); bwidth = width * 4; y_start = -1; - page_min = 0x7fffffff; - page_max = -1; + page_min = 0; + page_max = 0; d = s->ds->data; linesize = s->ds->linesize; y1 = 0; @@ -1592,9 +1593,9 @@ static void vga_draw_graphic(VGAState *s, int full_update) if (update) { if (y_start < 0) y_start = y; - if (page0 < page_min) + if (page_min == 0 || page0 < page_min) page_min = page0; - if (page1 > page_max) + if (page_max == 0 || page1 > page_max) page_max = page1; vga_draw_line(s, d, s->vram_ptr + addr, width); if (s->cursor_draw_line) diff --git a/tools/ioemu/vnc.c b/tools/ioemu/vnc.c index 129492f5e5..bea522ef27 100644 --- a/tools/ioemu/vnc.c +++ b/tools/ioemu/vnc.c @@ -457,6 +457,8 @@ static void _vnc_update_client(void *opaque) int maxx, maxy; int tile_bytes = vs->depth * DP2X(vs, 1); + qemu_mod_timer(vs->timer, now + VNC_REFRESH_INTERVAL); + if (vs->width != DP2X(vs, DIRTY_PIXEL_BITS)) width_mask = (1ULL << X2DP_UP(vs, vs->ds->width)) - 1; else @@ -496,7 +498,7 @@ static void _vnc_update_client(void *opaque) if (!vs->has_update || vs->visible_y >= vs->ds->height || vs->visible_x >= vs->ds->width) - goto out; + return; /* Count rectangles */ n_rectangles = 0; @@ -547,9 +549,6 @@ static void _vnc_update_client(void *opaque) vs->slow_client = 0; } else vs->slow_client = 1; - - out: - qemu_mod_timer(vs->timer, now + VNC_REFRESH_INTERVAL); } static void vnc_update_client(void *opaque) @@ -562,10 +561,8 @@ static void vnc_update_client(void *opaque) static void vnc_timer_init(VncState *vs) { - if (vs->timer == NULL) { + if (vs->timer == NULL) vs->timer = qemu_new_timer(rt_clock, vnc_update_client, vs); - qemu_mod_timer(vs->timer, qemu_get_clock(rt_clock)); - } } static void vnc_dpy_refresh(DisplayState *ds) @@ -902,6 +899,8 @@ static void framebuffer_update_request(VncState *vs, int incremental, vs->visible_y = y_position; vs->visible_w = w; vs->visible_h = h; + + qemu_mod_timer(vs->timer, qemu_get_clock(rt_clock)); } static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) -- 2.30.2